package com.alibaba.algo.dao.user;

import com.alibaba.algo.cooperation.feign.vo.req.GetUserOrgsReqVO;
import com.alibaba.algo.cooperation.feign.vo.req.SelectOrgUserEmployeeVO;
import com.alibaba.algo.cooperation.feign.vo.req.SelectUserListInfoReqVo;
import com.alibaba.algo.cooperation.feign.vo.res.RpcUserInfoVO;
import com.alibaba.algo.cooperation.usercomponent.vo.req.user.SelectRoleListByUserRequestVO;
import com.alibaba.algo.cooperation.usercomponent.vo.req.user.SelectUserListByAppRequestVO;
import com.alibaba.algo.cooperation.usercomponent.vo.req.user.SelectUserListRequestVO;
import com.alibaba.algo.cooperation.usercomponent.vo.res.user.EmployeeInfo;
import com.alibaba.algo.cooperation.usercomponent.vo.res.user.SelectUserDetailResponseVO;
import com.alibaba.algo.core.base.BaseMapper;
import com.alibaba.algo.dtos.user.UserOrgInfoResDTO;
import com.alibaba.algo.entity.user.SysUser;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 类SysUserMapper.java的实现描述：用户表Mapper
 *
 * @author nieganggang 2021-03-12 16:08:17
 */
public interface SysUserMapper extends BaseMapper<SysUser> {

    /**
     * 分页查询总数
     *
     * @param vo 入参
     * @return 总数
     */
    Integer countByPage(@Param("obj") SelectUserListRequestVO vo);

    Integer countByPageByApp(@Param("obj") SelectUserListByAppRequestVO vo);

    Integer countEntityByPage(@Param("obj") SelectUserListRequestVO vo);

    /**
     * 用户列表查询
     *
     * @param vo      条件
     * @param start   分页开始
     * @param end     分页结束
     * @param sortStr 排序
     * @return 用户列表
     */
    List<SelectUserDetailResponseVO> selectPage(@Param("obj") SelectUserListRequestVO vo, @Param("start") int start, @Param("end") int end, @Param("sort") String sortStr);

    List<SelectUserDetailResponseVO> selectPageEntity(@Param("obj") SelectUserListRequestVO vo, @Param("start") int start, @Param("end") int end, @Param("sort") String sortStr);

    List<SelectUserDetailResponseVO> selectPageByApp(@Param("obj") SelectUserListByAppRequestVO vo, @Param("start") int start, @Param("end") int end, @Param("sort") String sortStr);

    List<String> selectRoleListByUser(SelectRoleListByUserRequestVO vo);

    SysUser getByPhone(String mobile);

    SysUser getOneByEmployeeCode(String employeeCode);

    SysUser getOneByEmployeeCodeDefaultAll(@Param("employeeCode") String employeeCode,@Param("isDeleted") String isDeleted);

    /**
     * 通过多个角色ID查询用户信息列表
     * @param
     * @param sort
     * @return
     */
    List<RpcUserInfoVO> qryUserInfoByUserListOrAppCode(@Param("vo") SelectUserListInfoReqVo vo, @Param("sort") String sort);

    List<UserOrgInfoResDTO> selectOrgsByUser(@Param("vo") GetUserOrgsReqVO vo);

    List<SysUser> selectListByCondition(@Param("obj") SelectOrgUserEmployeeVO vo);

    List<EmployeeInfo> selectUserEmployeeListByCondition(@Param("obj") SelectOrgUserEmployeeVO vo);

    Integer countUserEmployeeListByCondition(@Param("obj") SelectOrgUserEmployeeVO vo);

    List<EmployeeInfo> selectUserEmployeeListByEmployeeCode(@Param("obj") SelectUserListRequestVO vo);

    List<EmployeeInfo> selectUserEmployeeListWithIsDeletedByEmployeeCode(@Param("obj") SelectUserListRequestVO vo);

    Integer deleteById(Long userId);

    Integer countByParaExtend(@Param("obj") SysUser sysUser);


    /**
     * 通过用户ID清单查询用户信息列表
     */
    List<SysUser> selectUserListByUserIds(@Param("ids") List<Long> userIds);

    /**
     * 通过工号ID清单查询用户信息列表
     */
    List<SysUser> selectUserListByEmployeeIds(@Param("ids") List<Long> employeeIds);

    /**
     * 通过组织ID清单查询用户信息列表
     */
    List<SysUser> selectUserListByOrgIds(@Param("ids") List<Long> orgIds);

    /**
     * 通过岗位ID清单查询用户信息列表
     */
    List<SysUser> selectUserListByPositionIds(@Param("ids") List<Long> positionIds);

    /**
     * 通过角色ID清单查询用户信息列表
     */
    List<SysUser> selectUserListByRoleIds(@Param("ids") List<Long> roleIds);

    /**
     * 通过人员组ID清单查询用户信息
     */
    List<SysUser> selectUserListByGroupIds(@Param("ids") List<Long> roleIds);

    /**
     * 通过人员组ID清单和组织查询用户信息
     */
    List<SysUser> selectUserListByGroupIdsAndOrg(@Param("ids") List<Long> roleIds);

    /**
     * 查询用户列表，默认查全部
     */
    List<SysUser> listByParaDefaultAll(@Param("obj") SysUser sysUser, @Param("sort") String sort);

    SysUser getByIdDefaultAll(@Param("id") Long id,@Param("isDeleted") String isDeleted);

    Integer updateEmployeeCodeByUserId(@Param("obj") SysUser entity);

    Integer updateByIdWithIsDeleted(@Param("obj") SysUser entity);

    Integer updateByIdWithEmptyProperties(@Param("obj") SysUser entity);

    SysUser getByIdWithIsDeleted(@Param("id") Long id);

    List<Map<String, String>> checkEmpIsNotActive(@Param("ecodes") List<String> ecodes);

    Integer getRegisteredUserCount();
}
